package cn.anzhiyublog.staranimegallery.util;

import cn.anzhiyublog.staranimegallery.model.enums.StatusCode;
import cn.anzhiyublog.staranimegallery.model.response.Response;

/**
 * 快捷构造响应包装
 *
 * @author 安知一只鱼
 */
public class ResultUtils {

    public static <T>Response<T> success(T data){
        return new Response<>(StatusCode.SUCCESS.getCode(), data, StatusCode.SUCCESS.getMessage());
    }

    public static Response<?> error(StatusCode statusCode){
        return new Response<>(statusCode.getCode(),null,statusCode.getMessage());
    }

    public static Response<?> error(StatusCode statusCode, String message){
        return new Response<>(statusCode.getCode(),null, message);
    }

    public static Response<?> error(int code, String message) {
        return new Response<>(code,null, message);
    }
}
